package org.whale.springcloud.eureka.user.zuul.application;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;

/** Zuul的主要功能是路由转发和过滤器 */
@SpringBootApplication
@ComponentScan(basePackages = "org.whale.springcloud.eureka.user.zuul")
@EnableZuulProxy // 路由
@EnableEurekaClient
@EnableDiscoveryClient
public class EurekaUserZuulApplication {

  private static final Logger logger = LoggerFactory.getLogger(EurekaUserZuulApplication.class);

  public static void main(String[] args) {
    SpringApplication.run(EurekaUserZuulApplication.class, args);

    logger.info("user ribbon app start");
  }

  @Bean
  @LoadBalanced // 负载均衡
  public RestTemplate restTemplate() {
    return new RestTemplate();
  }
}
